package com.bds.tjj.config;

import com.bds.tjj.filter.SessionInterceptor;

import org.nutz.dao.impl.NutDao;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.HashSet;
import java.util.Set;

import javax.annotation.Resource;

/**
 * Created by guoyu on 2018/1/29.
 */
@Configuration
public class SessionConfig extends WebMvcConfigurerAdapter {
	@Resource
	private NutDao dao;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		SessionInterceptor sessionInterceptor = new SessionInterceptor(dao);
		Set<String> writeUrls = new HashSet<>();
		// writeUrls.add("/page/login.html");

		writeUrls.add("/service/user/loginto");
		writeUrls.add("/service/user/signUp");

		sessionInterceptor.setWriteUrls(writeUrls);
		registry.addInterceptor(sessionInterceptor).addPathPatterns("/**");
		super.addInterceptors(registry);
	}
}
